package com.ssd.api.couponAndIntegral;

import com.ssd.api.couponAndIntegral.dto.AvailableCouponsResDTO;
import com.ssd.api.couponAndIntegral.dto.CouponUseBackReqDTO;
import com.ssd.api.couponAndIntegral.dto.CouponUseReqDTO;
import com.ssd.api.couponAndIntegral.dto.CouponUseResDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;

/**
 * 内部接口-优惠券接口
 */
@FeignClient(name = "couponIntegral-service", url = "http://localhost:9020/couponIntegral-service/inner/coupon")
public interface CouponApi {

    /**
     *根据金额计算用户可用优惠券列表
     * @param totalAmount 金额
     * @return
     */
    @GetMapping("/getAvailable")
    public List<AvailableCouponsResDTO> gatAvailable(@RequestParam("totalAmount") BigDecimal totalAmount);

    /**
     * 使用优惠券，并返回优惠金额
     * @param couponUseReqDTO 使用优惠券参数
     * @return
     */
    @PostMapping("/use")
    public CouponUseResDTO use(@RequestBody CouponUseReqDTO couponUseReqDTO);


    /**
     * 优惠券回退接口
     * @param couponUseBackReqDTO 回退参数
     */
    @PostMapping("/useBack")
    public void useBack(@RequestBody CouponUseBackReqDTO couponUseBackReqDTO);
}
